﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Asn1.Ocsp;
using Swashbuckle.AspNetCore.Annotations;
using System.Threading.Tasks;
using VisionCloud.Domain.Common;
using VisionCloud.Domain.DtoModel.Ms;
using VisionCloud.Domain.Filters;
using VisionCloud.Service.Demo;

namespace VisionCloud.Api.Controllers.Demo
{
    /// <summary>
    /// 外立面
    /// </summary>
    [SystemModule("外立面演示接口")]
    [ApiVersion("1.0")]
    [Route("api/demo/[controller]/[Action]")]
    [ApiExplorerSettings(GroupName = "外立面演示接口")]
    [AllowAnonymous]
    public class ExternalWallController : ApiBaseController
    {
        public ExternalWallService ExternalWallService { get; set; }

        /// <summary>
        /// 分页获取所有项目名称
        /// </summary>
        [HttpPost]
        [SwaggerResponse(0, "获取详情数据的字段：Result", typeof(ApiResultBase<ApiPageResult<string>>))]
        public async Task<ApiResult> GetProjectName(PageRequest request)
        {
            var res = await Task.Run(() => ExternalWallService.GetProjectName(request));
            return new ApiResult { Code = AjaxCode.Success, Result = res };
        }

        /// <summary>
        /// 上传外立面任务zip数据
        /// </summary>
        [HttpPost]
        [SwaggerResponse(0, "获取详情数据的字段：Result", typeof(ApiResultBase<bool>))]
        public async Task<ApiResult> UploadFile(IFormFile file)
        {
            var res = await ExternalWallService.UploadFile(file);
            return new ApiResult { Code = AjaxCode.Success, Result = res };
        }

        /// <summary>
        /// 获取项目下所有的任务名称
        /// </summary>
        [HttpPost]
        [SwaggerResponse(0, "获取详情数据的字段：Result", typeof(ApiResultBase<ApiPageResult<ProjectReportDto>>))]
        public async Task<ApiResult> GetTaskName(QueryReportByproject request)
        {
            var res = await Task.Run(() => ExternalWallService.GetTaskName(request));
            return new ApiResult { Code = AjaxCode.Success, Result = res };
        }

        /// <summary>
        /// 批量删除任务报告数据
        /// </summary>
        [HttpPost]
        [SwaggerResponse(0, "获取详情数据的字段：Result", typeof(ApiResultBase<bool>))]
        public async Task<ApiResult> DeleteReports(DeleteTaskDataDto dto)
        {
            var res = await Task.Run(() => ExternalWallService.DeleteReports(dto));
            return new ApiResult { Code = AjaxCode.Success, Result = res };
        }

        /// <summary>
        /// 获取3D数据
        /// </summary>
        [HttpPost]
        [SwaggerResponse(0, "获取详情数据的字段：Result", typeof(ApiResultBase<ExternalWallDataDetail>))]
        public async Task<ApiResult> GetDetail(ProjectTaskName dto)
        {
            var res = await Task.Run(() => ExternalWallService.GetDetail(dto));
            return new ApiResult { Code = AjaxCode.Success, Result = res };
        }
    }
}